package br.com.ciandt.android;

import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import br.com.ciandt.android.bd.dao.PodCastDao;
import br.com.ciandt.android.bd.dao.impl.PodCastDaoImpl;
import br.com.ciandt.android.bd.ex.k.DataHelper;
import br.com.ciandt.android.to.PodCast;

public class PodCastCiandtAndroid extends Activity {
    /** Called when the activity is first created. */
   

	private TextView output;
	
	private ListView listRSS;
	private ListView listRSSItens;

	private DataHelper dh;
	
	static String[] arrRSS;
	
	static final String[] arrRSSItens = new String[] {
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos.",
		"Leia as noticias do dia e fique atualizado com seus RSS favoritos."
	};

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);

		setContentView(R.layout.main);
		
		this.listRSS = (ListView)this.findViewById(R.id.lvRss);
		PodCastDao podCastDao = new PodCastDaoImpl(getApplicationContext());
		List<PodCast> lstPodCast = podCastDao.selectAll();
		arrRSS = new String[lstPodCast.size()];
		// TODO Criar um listadapter
		for(int i = 0; i < lstPodCast.size(); i++) {
			arrRSS[i] = lstPodCast.get(i).getDescricao();
		}
		this.listRSS.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1 , arrRSS));
		
		this.listRSSItens = (ListView)this.findViewById(R.id.lvRssItens);
		this.listRSSItens.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1 , arrRSSItens));
		
		this.output = (TextView) this.findViewById(R.id.TextView01);

		// this.dh = new DataHelper(this);
		// this.dh.insert("a - " + new Date().toString());
		// this.dh.insert("b - " + new Date().toString());
		// this.dh.insert("c - " + new Date().toString());
		// List<String> names = this.dh.selectAll();
		// StringBuilder sb = new StringBuilder();
		// sb.append("Names in database:\n");
		// for (String name : names) {
		// sb.append(name + "\n");
		// }

		// Log.d("EXAMPLE", "names size - " + names.size());
		//
		// this.output.setText(sb.toString());

		this.output.setText(podCastDao.selectAll().toString());
		
	}
}